﻿@using Website.CRUDServices
@{
    this.ViewBag.Title = "Ny Nyhedsinformation";
    this.Layout = "~/Views/_Shared/_Layout.cshtml";
    var Funds = this.ViewData["Funds"] as List<Fund>;
    var Projects = this.ViewData["Projects"] as List<Project>;
    var Types = this.ViewData["Types"] as List<NewsInformationType>;
    var errorMsg = new HtmlString(string.Empty);
    if (this.ViewData["ErrorMessage"] != null)
    {
        errorMsg = this.ViewData["ErrorMessage"] as HtmlString;
    }

}
<script type="text/javascript">
    //toggle script
    function toggle(id) {
        if (document.getElementById(id).style.display == 'none' || document.getElementById(id).style.display == "") {
            document.getElementById(id).style.display = 'block';
        } else {
            document.getElementById(id).style.display = 'none';
        }
    }

    function reverseToggle(id) {
        if (document.getElementById(id).style.display == 'block') {
            document.getElementById(id).style.display = 'none';
        } else {
            document.getElementById(id).style.display = 'block';
        }
    }

//show/his script

    function checkType(id) {
        if (document.getElementById('Type').value == 'Nyhedsbrev') {
            toggle(id);
        } else {
            if (document.getElementById('Type').value == 'Formidlings information') {
                toggle(id);
            } else {
                reverseToggle(id);
            }
        }
    }
</script>
<script>
    //datepicker script
    $(function() {
        $("#datepicker").datepicker();
        $('#Funds').multiSelect();
        $('#OwnerProjects').multiSelect();

    });
</script>

@using (this.Html.BeginForm("NewNewsInformation", "NewsInformation", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div class="error">
        @errorMsg
    </div>

    // *******************Nyhedsinformation*************************
    // name
    <div class="formBullet">Navn på nyhedsinformation</div>
    <input type="text" id="Name" name="Name" />

    // date
    <div class="formBullet">Dato</div>
    <input type="text" id="datepicker" name="TimeOfActivity" readonly="readonly" value="" />

    // ownerProjects chooser
    <div class="formBullet">Alle projekter tilknyttet</div>
    <div class="formEntry">
        <select multiple="multiple" name="OwnerProjects" id="OwnerProjects">
            @foreach (Project proj in Projects)
            {
                <option value="@proj.ID">@proj.Name</option>
            }
        </select>
    </div>

    // types chooser
    <div class="formBullet">Nyhedstype</div>
    <div class="formEntry">
        <select name="Type" id="Type" onchange=" checkType('additionals') ">
            @foreach (NewsInformationType typ in Types)
            {
                <option value="@typ.ID">@typ.Name</option>
            }
        </select>
    </div>

    // explanation
    <div class="formBullet">Hvad handler nyhedsinformationen om?</div>
    <textarea name="Comments" id="Comments"></textarea>

    <!--filechooser-->
    <div class="formBullet">
        Fil til arkivering<br />
    </div>
    <div class="formEntry">
        @FileUpload.GetHtml("Files", 1, true, false, "Tilføj flere filer", "Vælg fil til arkivering")
    </div>
    <!--archive location-->
    <div class="formBullet">Fysisk arkiverings placering</div>
    <input type="text" id="ArchiveLocation" name="ArchiveLocation" />

    <div id="additionals" class="open_hidden">
        <div class="formBullet">Information om:</div>
        <label><input type="checkbox" name="informationType" value="funds" onchange=" toggle('showFunds') " />Fonde/puljer</label><label><input type="checkbox" name="informationType" value="progress" />Fremdrift</label><label><input type="checkbox" name="informationType" value="results" />Resultater</label>
        <div id="showFunds" class="open_hidden">
            <!--Funds-->
            <div class="formBullet">Vælg fonde/puljer</div>
            <div class="formEntry">
                <select multiple="multiple" name="Funds" id="Funds">
                    @foreach (Fund fun in Funds)
                    {
                        <option value="@fun.ID">@fun.Name</option>
                    }
                </select>
                <script src="@Url.Content("jquery.multi-select.js")" type="text/javascript"> </script>
            </div>
        </div>
    </div>

    <div class="buttonHolder">
        <input type="submit" value="Opret" />
    </div>
}